package hu.mapro.gamelib.misc;

import com.badlogic.gdx.graphics.g2d.PolygonRegion;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Textures {

	public static void textureMap(PolygonRegion region, float scale) {
		float[] textureCoords = region.getTextureCoords();
		TextureRegion textureRegion = region.getRegion();
		float u = textureRegion.getU(), v = textureRegion.getV();
		float uvWidth = textureRegion.getU2() - u;
		float uvHeight = textureRegion.getV2() - v;
		float width = textureRegion.getRegionWidth() * scale;
		float height = textureRegion.getRegionHeight() * scale;
		float[] vertices = region.getVertices();
		for (int i = 0, n = vertices.length; i < n; i++) {
			textureCoords[i] = u + uvWidth * (vertices[i] / width);
			i++;
			textureCoords[i] = v + uvHeight * (1 - (vertices[i] / height));
		}
		
	}

	
}
